<style lang="scss" scoped>
	.content {

		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.nav {
		width: 100%;
		position: fixed;
		top: 0;
		left: 0;
		padding-bottom: 10rpx;
		border-bottom: 1px solid #dee2ee;
		background-color: white;
		z-index: 999;
	}

	.top {
		padding: 20rpx 30rpx;
	}

	.search {
		width: 554rpx;
		height: 76rpx;
		background: #f4f5f7;
		border: 2rpx solid #f5f5f5;
		border-radius: 46rpx;
		padding: 20rpx;

		.ipt {
			flex: 1;
		}
	}


	.lists {
		margin-bottom: 50rpx;

		.list {
			width: 690rpx;

			opacity: 1;
			background: #ffffff;
			border-radius: 20rpx;
			box-shadow: 0rpx 30rpx 18rpx -14rpx #e6ebf2;
			overflow: hidden;
			margin-top: 30rpx;


			.contains {
				width: 100%;
				padding: 20rpx;

				.text {
					width: 620rpx;
					line-height: 60rpx;

					.tip {
						width: 140rpx;
					}
				}
			}


		}
	}

	.line {
		>view {
			width: 50%;
		}
	}

	.des {
		width: 100%;
		line-height: 40rpx;
		position: relative;
		text-align: justify;

		.blue {
			position: absolute;
			bottom: 0;
			right: 0;
		}
	}

	.btns {
		width: 100%;
		justify-content: flex-end;

		.btn1 {
			width: 184rpx;
			height: 64rpx;
			opacity: 1;
			background: #ffffff;
			border: 2rpx solid #dee2ee;
			border-radius: 44rpx;
		}

		.btn2 {
			width: 184rpx;
			height: 64rpx;
			opacity: 1;
			background: #fffefe;
			border: 2rpx solid #409eff;
			border-radius: 34rpx;
		}
	}
</style>

<template>
	<view class="content">
		<view class="nav bgwhite" id="nav">
			<!-- <view class="top bgwhite between-flex">
				<view class="search align-flex">
					<u-icon name="search" color="#666" size="34"></u-icon>
					<input @input="search" class="ipt p-left20" type="text" v-model="keywords" placeholder="搜索会议" />
				</view>
				<view class="add colum-flex blue" @click="$navTo(PagesHuiYiRouterConfig.Yuding)">
					<u-icon name="plus-circle" size="40"></u-icon>
					<view class=" f24 m-top10">预约</view>
				</view>
			</view> -->
			<Search :iconType="CustomIconFontName.Reserve" @onIcon="$navTo(PagesHuiYiRouterConfig.Yuding)"></Search>
			<u-tabs :list="nav" :is-scroll="false" bar-width="60" bar-height="4" :current="current" @change="change"></u-tabs>
		</view>
		<view :style="'height:'+navheight+'px;'"></view>
		<view class="lists">
			<view class="list" v-for="item,index in list" :key="index" @click="goDetail(item)">
				<view class="between-flex p-left20 p-right20 p-top20">
					<view class="align-flex">
						<view class="gray ">会议时间: {{item.time}} {{item.startTime}}-{{item.endTime}}</view>
					</view>
					<view class="blue" :style="{color:$meetingState(item.flag).color}">
						{{$meetingState(item.flag).name}}
					</view>
				</view>
				<u-line margin="20rpx 0 0 0"></u-line>
				<view class="contains between-flex">
					<view class="text">

						<view class="textColor bold f34">{{item.title}}</view>
						<view class="align-flex">
							<view class="gray tip">主持人 </view><span class="textColor">{{item.hostsName}}</span>
						</view>
						<view class="align-flex">
							<view class="gray tip">参会人员 </view><span class="textColor align-flex"><span class="one" style="max-width:350rpx;display: inline-block;">{{item.attendsName}}
								</span>等{{item.attends.length}}人</span>
						</view>
						<view class="flex">
							<view class="gray tip">会议地址 </view>
							<view class="textColor " style="width:500rpx;">{{item.meetingRoomName}}{{item.address}}</view>
						</view>
					</view>
					<u-icon name="arrow-right" color="#98a5b3" size="28"></u-icon>
				</view>

			</view>
		</view>
		<view class="center-flex c999 f24" v-if="nomore">-没有更多了-</view>
		<view v-if="empty" style="position: fixed;top:40%;left:50%;transform: translateX(-50%);">
			<u-empty text="暂无列表"></u-empty>

		</view>
		<u-popup mode="bottom" v-model="showPopup" :closeable="true" borderRadius="20" :height="type==3?'90%':''">
			<ChangeCom></ChangeCom>
		</u-popup>
	</view>


</template>

<script>
	import ChangeCom from '@/pagesHuiyi/operation/change.vue'
	import PagesHuiYiRouterConfig from '@/pagesHuiyi/routerConfig.js'
	import Search from '@/components/input/index.vue'
	import CustomIconFontName from '@/common/customIconFontName.js'
	export default {
		components: {
			ChangeCom,
			Search
		},
		data() {
			return {
				PagesHuiYiRouterConfig,
				CustomIconFontName,
				navheight: 0,
				head: this.$head,
				nav: [{
						name: '我主持的',
						count: 0,
						type: 1
					}, {
						name: '我参加的 ',
						count: 0,
						type: 2
					},
					{
						name: '待我审核 ',
						count: 0,
						type: 3
					},
					{
						name: '我创建的 ',
						count: 0,
						type: 4
					}
				],
				current: 0,
				showPopup: false,
				keywords: '',
				page: 1,
				list: [],
				nomore: false,
				empty: false,

			}
		},
		onLoad() {
			setTimeout(() => {
				let info = uni.createSelectorQuery().select("#nav");
				info.boundingClientRect((data) => {

					this.navheight = data.height

					console.log(this.navheight)
				}).exec()
			}, 700)

		},
		onShow() {
			this.reset()

		},
		onReachBottom() {
			if (!this.nomore) {
				this.page++
				this.getlist()
			}
		},
		methods: {
			goDetail(item) {
				if (item.flag == 3) {
					this.$navTo(PagesHuiYiRouterConfig.HuiyiDetail + '?id=' + item.id + '&type=3')

				} else {
					this.$navTo(PagesHuiYiRouterConfig.HuiyiDetail + '?id=' + item.id + '&type=' + this.current)
				}

			},
			search() {
				this.$u.debounce(this.reset, 500)

			},
			reset() {
				this.$showloading()
				this.page = 1
				this.list = []
				this.nomore = false
				this.getlist()
				this.getRedInfo()
			},
			getRedInfo() {
				this.$pop.ajaxPost('/bus/busMeeting/getMeetingStatistics').then(res => {
					this.nav[0].count = res.body.myHostMeeting
					this.nav[1].count = res.body.myAttendMeeting
					this.nav[2].count = res.body.myAuditMeeting
					this.nav[3].count = res.body.myCreateMeeting
				})

			},
			getlist() {

				this.$pop.ajaxPost('/bus/busMeeting/getMyMeeting', {
					keyword: this.keywords,
					pageNum: this.page,
					pageSize: 10,
					type: this.nav[this.current].type
				}).then(res => {
					uni.hideLoading()
					var list = res.body.list
					list.forEach(item => {
						let attendsName = []
						let hostsName = []
						item.attends.forEach(item2 => {
							attendsName.push(item2.userName)
						})
						item.hosts.forEach(item2 => {
							hostsName.push(item2.userName)
						})
						item.attendsName = attendsName.join(',')
						item.hostsName = hostsName.join(',')
					})
					this.list = this.list.concat(list)

					if (this.list.length == 0) {
						this.empty = true
					} else {
						this.empty = false
						if (list.length < 10) {
							this.nomore = true
						} else {
							this.nomore = false
						}
					}

				})
			},

			change(index) {
				this.current = index;
				this.reset()
			}

		}
	}
</script>
